<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0054)http://technoplaza.suso.org/assembly/index.cgi?p=68ks2 -->
<HTML><HEAD><TITLE>The Stack, Handles, and Errors</TITLE>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type>
<META content="MSHTML 5.00.2314.1000" name=GENERATOR>
<link href="edit68k.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY bgColor=#ffffff>
<H1 class="heading">The Stack<br>
    <hr noshade>
</H1>
<P align=left class="text">As mentioned earlier, A7 functions as the stack pointer. The stack ( user and system stack ) is stored in the "system memory": you should not worry about the size: it should always be more than enough. You may have noticed, if you jumped to the instruction summary at first: there are no push/pop instructions! That's because they're not necessary, MOVE will do both jobs for us.<BR>
          <BR>
  For example, if we want to push D0.W (with this I mean D0, the lower 16 bits) we just MOVE.W D0,-(A7). And to pop it back, just MOVE.W (A7)+,D0. Remember that when popping a word, the upper 16 bits in D0 are still there.<BR>
          <BR>
  When you want to push more than one register at the same time, for example in the beginning of a subroutine, it may be a bit time consuming to type all the move instructions. There is a shortcut: MOVEM. With this instruction you can push (or just copy) many registers at once. If you want to push D0-D4 and A0-A2 for example, you just movem d0-d4/a0-a2,-(a7) and then movem (a7)+,d0-d4/a0-a2.<BR>
          <BR>
  Another way to put things on the stack is with the PEA instruction. It pushes an effective address on the stack, used when pushing pointers. This will decrease A7 with 4 (the size of a pointer).</P>
<H4 align=left> </H4>
</BODY>
</HTML>
